<template>
  <el-dialog :fullscreen="max" :close-on-click-modal="false" :visible.sync="visible">
    <div slot="title">
      <span>入住</span>
      <button type="button" style="right: 50px;" class="el-dialog__headerbtn" @click="max = !max">
        <i class="el-dialog__close el-icon el-icon-copy-document" v-if="max"></i>
        <i class="el-dialog__close el-icon el-icon-full-screen" v-else></i>
      </button>
    </div>
    <div class="ruzhu">
      <el-form :model="dataForm" ref="dataForm" label-width="80px">
        <el-row>
          <el-col :span="9" class="ruzhu-left" style="overflow: hidden;">
            <el-card shadow="hover" style="margin-bottom: 15px;">
              <div slot="header" class="clearfix"><span>订价信息</span></div>
              <div class="ant-card-body">
                <el-form-item label="入住类型" prop="checkinType">
                  <!-- 入住类型（0全天1时租2自用3免费） -->
                  <el-select v-model="dataForm.checkinType" @change="checkinTypeChange" placeholder="请选择">
                    <el-option label="全天" :value="0"></el-option>
                    <el-option label="时租" :value="1"></el-option>
                    <el-option label="自用" :value="2"></el-option>
                    <el-option label="免费" :value="3"></el-option>
                    <el-option label="长包" :value="4"></el-option>
                  </el-select>
                </el-form-item>
                <el-form-item label="入住时间" prop="arrivalsTime">
                  <el-row>
                    <el-col :lg="12" :sm="24" :xs="24">
                      <el-date-picker disabled v-model="date.startDate1" value-format="yyyy-MM-dd" type="date"
                                      placeholder="选择日期"></el-date-picker>
                    </el-col>
                    <el-col :lg="12" :sm="24" :xs="24">
                      <el-time-select class="ruzhu-ruzhushij" :clearable="false" :disabled="true"
                                      v-model="date.startDate2"
                                      :picker-options="{
                          start: '00:00',
                          step: '00:01',
                          end: '23:55'
                        }"
                                      placeholder="选择时间"></el-time-select>
                    </el-col>
                  </el-row>
                </el-form-item>
                <el-form-item label="预离时间" prop="predissociationTime" v-if="dataForm.checkinType != 1">
                  <el-row>
                    <el-col :lg="12" :sm="24" :xs="24">
                      <el-date-picker :clearable="false" v-model="date.stopDate1" value-format="yyyy-MM-dd"
                                      @change="stopDate2Change"
                                      :picker-options="pickerOptions" type="date"
                                      placeholder="选择日期"></el-date-picker>
                    </el-col>
                    <el-col :lg="12" :sm="24" :xs="24">
                      <el-time-select class="ruzhu-ruzhushij" :clearable="false" v-model="exitPoint" :picker-options="{
                          start: '12:00',
                          step: '00:01',
                          end: '18:00'
                        }"
                                      placeholder="选择时间"></el-time-select>
                    </el-col>
                  </el-row>
                </el-form-item>
                <el-form-item label="时长" prop="days" v-if="dataForm.checkinType == 1">
                  <el-select v-model="dataForm.housId" @change="hoursChange" placeholder="请选择">
                    <el-option v-for="item in options.housOptions" :key="item.id" :label="item.name"
                               :value="item.id"></el-option>
                  </el-select>
                </el-form-item>
                <el-form-item label="客人来源" prop="checkinType">

                  <el-select v-model="dataForm.sourceAgreenid" @change="getschemelist()" placeholder="请选择">
                    <el-option v-for="item in userly" :key="item.id" :label="item.label" :value="item.id">
                    </el-option>
                  </el-select>
                </el-form-item>

                <el-form-item label="早餐">
                  <el-input-number :min="0" v-model="dataForm.zc" :step="1" step-strictly></el-input-number>
                </el-form-item>

                <el-form-item label="天数" v-if="dataForm.checkinType != 1">
                  <el-input-number @change="daysChange" :min="1" v-model="dataForm.days" :step="1"
                                   step-strictly></el-input-number>
                </el-form-item>

                <el-form-item label="客人类型" prop="sourceType">
                  <el-row>
                    <el-col :span="10">
                      <el-select v-model="dataForm.sourceType" placeholder="请选择">
                        <el-option v-for="item in sourceTypeOptions" :key="item.value" :label="item.label"
                                   :value="item.value"></el-option>
                      </el-select>
                    </el-col>
                    <el-col :span="12" style="margin-left: 10px;">
                      <el-select clearable v-if="dataForm.sourceType == 1" @change="sellerMenberChange"
                                 v-model="dataForm.sourceName"
                                 filterable remote reserve-keyword placeholder="姓名/手机号/身份证号"
                                 :remote-method="remoteMethod"
                                 :loading="loading">
                        <el-option v-for="item in options.sellerMenberOp" :key="item.id" :label="item.name"
                                   :value="item.id"></el-option>
                      </el-select>
                      <el-input v-if="dataForm.sourceType == 3" v-model="dataForm.sourceName"
                                placeholder="名称/简称/联系人"></el-input>
                      <el-select v-if="dataForm.sourceType == 2" @change="sellerxieyiChange" clearable
                                 v-model="dataForm.sourceName"
                                 filterable remote reserve-keyword placeholder="名称/编号/手机号"
                                 :remote-method="sellerxieyiChange"
                                 :loading="loading">
                        <el-option v-for="item in listrestaurants" :key="item.values" :label="item.value"
                                   :value="item.values"></el-option>
                      </el-select>
                    </el-col>
                    <el-col :span="8" style="margin-left: 10px;" v-if="dataForm.sourceType == 2">
                      <span style="color: red;" @click="showagreement=true">{{ agreemxyrows.name }}</span>
                    </el-col>
                  </el-row>
                </el-form-item>
                <el-form-item label-width="0" v-if="dataForm.sourceType == 2">
                  <div class="customerSourceBar" style="margin-bottom: 0;">
                    <div>
                      <div class="in_block">
                        <label class="fourChar">姓名:</label>
                        <span v-cloak>{{ rename }}</span>
                      </div>
                      <div class="in_block">
                        <label>电话:</label>
                        <label>{{ retel }}</label>
                      </div>
                      <div class="in_block">
                        <label class="fourChar">余额:</label>
                        <span>{{ recha }}</span>
                      </div>
                    </div>
                    <div>
                      <div class="in_block">
                        <label>预收款:</label>
                        <span>{{ reyshouk }}</span>
                      </div>
                      <div class="in_block">
                        <label class="threeChar">已结算:</label>
                        <span>{{ reyjs }}</span>
                      </div>
                      <div class="in_block">
                        <label class="threeChar">未结算:</label>
                        <span>{{ reweijs }}</span>
                      </div>
                    </div>
                  </div>
                </el-form-item>
                <el-form-item label-width="0" v-if="dataForm.sourceType == 1">
                  <div class="customerSourceBar" style="margin-bottom: 0;">
                    <div>
                      <div class="in_block">
                        <label class="fourChar">姓名:</label>
                        <label>{{ selectSellerMenber.name }}</label>
                      </div>
                      <div class="in_block">
                        <label>电话:</label>
                        <label>{{ selectSellerMenber.tel }}</label>
                      </div>
                      <div class="in_block">
                        <label class="fourChar">级别:</label>
                        <label>{{ selectSellerMenber.levelName }}</label>
                      </div>
                    </div>
                    <div>
                      <div class="in_block">
                        <label>余额:</label>
                        <label>{{ selectSellerMenber.balance }}</label>
                      </div>
                      <div class="in_block">
                        <label class="threeChar">积分:</label>
                        <label>{{ selectSellerMenber.score }}</label>
                      </div>
                      <div class="in_block">
                        <label class="threeChar">卡号:</label>
                        <label>{{ selectSellerMenber.cardJustNo }}</label>
                      </div>
                    </div>
                  </div>
                </el-form-item>
                <!--                <el-form-item label="房价方案" v-if="dataForm.checkinType != 1">
                <el-select v-model="dataForm.schemeId" clearable >
                  <el-option v-for="item in schemelist" :key="item.id" :label="item.name"   :value="item.id"></el-option>
                </el-select>
                </el-form-item> -->
                <el-form-item label="房价方案" v-if="dataForm.checkinType != 1">
                  <el-select @clear="handleSelect" clearable @change="handleSelect" v-model="dataForm.schemeId"
                             filterable remote reserve-keyword placeholder="名称/编号/手机号"
                             :remote-method="querySearchAsync"
                             :loading="dataListLoadings">
                    <el-option v-for="item in listrestaurantsa" :key="item.id" :label="item.value"
                               :value="item.id"></el-option>
                  </el-select>
                </el-form-item>

              </div>
            </el-card>
            <el-card shadow="hover" style="">
              <div slot="header" class="clearfix"><span>其他信息</span></div>
              <div class="ant-card-body ant-card-body-other">
                <el-row>
                  <el-col :span="14">
                    <el-form-item label="销售员">
                      <!--                      <el-input v-model="dataForm.saleId" placeholder="销售员"></el-input> -->
                      <el-select v-model="dataForm.saleId" filterable clearable placeholder="销售员">
                        <el-option v-for="item in tmarketingList" :key="item.id" :label="item.name" :value="item.id">
                        </el-option>
                      </el-select>
                    </el-form-item>
                  </el-col>
                  <el-col :span="10">
                    <el-form-item label="担保方式" class="ruzhu-dangbbao">
                      <el-select v-model="dataForm.guaranteeType" placeholder="请选择">
                        <el-option v-for="item in guaranteeTypeOptions" :key="item.value" :label="item.label"
                                   :value="item.value"></el-option>
                      </el-select>
                    </el-form-item>
                  </el-col>
                </el-row>
                <el-form-item label="外部单号">
                  <el-input v-model="dataForm.externalNo" placeholder="外部单号"></el-input>
                </el-form-item>
                <el-form-item label="备注">
                  <el-input v-model="dataForm.remarks" placeholder="备注" type="textarea" :rows="2"></el-input>
                </el-form-item>
              </div>
            </el-card>
          </el-col>
          <el-col :span="15">
            <el-card shadow="hover" style="margin-bottom: 15px;">
              <div slot="header" class="clearfix"><span>办理入住</span></div>
              <div class="ant-card-body" v-loading="roomLoading" :element-loading-text="$t('Common.LoadingText')">
                <div class="title_day_price clear_float">
                  <div class="pull">
                    <div style="cursor: pointer;">
                      <div class="in_block">
                        <span>房间数：</span>
                        <span>{{ addRoomsList.length }}间</span>
                      </div>
                      <div class="in_block">
                        <span>占房天数：</span>
                        <span>{{ dataForm.roomsDays }}晚</span>
                      </div>
                      <div class="in_block">
                        <span>总价：</span>
                        <span class="red_color1">￥ {{ dataForm.totalPrice ? dataForm.totalPrice.toFixed(2) : 0 }}</span>
                      </div>
                    </div>
                  </div>
                  <div class="push">
                    <el-button type="danger" size="small" @click="addRoomsBtn">添加房间</el-button>
                  </div>
                </div>
                <div v-if="addRoomsList.length > 0">
                  <div style="margin: 8px 0px;max-height: 300px;overflow-y: auto;">
                    <div v-for="(item, index) in addRoomsList" :key="index">
                      <div class="col_one clear_float" v-if="!item.prices.hoursMoney">
                        <div class="push" @click="removeRoom(item, index)"><a>删除房间</a></div>
                        <div class="pull">
                          <span style="display: inline-block;">{{ item.roomSign }}{{ item.roomNum }}</span>
                          <span style="display: inline-block;">{{ item.roomName }}</span>
                          <span style="display: inline-block;">该房型不支持此入住类型</span>
                        </div>
                      </div>

                      <div class="col_one clear_float" v-if="item.prices.hoursMoney">
                        <div class="push">
                          <a @click="addpeople(item, index)">添加同住</a>
                          <div class="ant-divider ant-divider-vertical"></div>
                          <a type="text" @click="removeRoom(item, index)">删除房间</a>
                        </div>
                        <div class="pull">
                          <span>房号：{{ item.roomSign }}{{ item.roomNum }}</span>
                          <span>
                            房型：
                            <span style="display: inline-block;">{{ item.roomName }}</span>
                          </span>
                          <span>
                            <div>
                              <span style="color: rgb(232, 80, 80);">优惠价：</span>
                              <label>{{ item.prices.dateList[0][date.startDate1] }}</label>
                              <el-popover v-if="dataForm.checkinType != 1" placement="bottom"
                                          @show="editRoomPrice(item)"
                                          trigger="hover">
                                <!-- 新版-->
                                <div class="ant-popover-inner-content">
                                  <div class="recent_price_ul table_recent_price_ul">
                                    <table>
                                      <thead>
                                        <tr>
                                          <th>
                                            <div class="list_box clear_float"><span>批量改价</span></div>
                                          </th>
                                          <th>
                                            <div class="list_box clear_float">
                                              <span style="width: 100%;">价格</span>
                                            </div>
                                          </th>
                                        </tr>
                                      </thead>
                                      <tbody>
                                        <tr>
                                          <td style="text-align: center; position: relative;">
                                            <div class="list_box clear_float"
                                                 style="position: absolute; top: 0px; bottom: 0px;"><span>
                                                <div>每日房价</div>
                                                <div>
                                                  <el-input-number @change="piliangChengPriceHead"
                                                                   v-model="editPriceSync.price"
                                                                   size="mini" :precision="2" :step="100"
                                                                   :min="0"></el-input-number>
                                                </div>
                                              </span>
                                            </div>
                                          </td>
                                          <td>
                                            <div class="list_box clear_float">
                                              <span v-for="(priceItem, index) in setPrice.prices.dateList"
                                                    v-if="index < dataForm.days"
                                                    :key="setPrice.roomId + ':' + index">
                                                <div>{{ dateList[index] }}</div>
                                                <div style="margin-bottom: 6px;">
                                                  <el-input-number size="mini"
                                                                   @change="changeTotal(priceItem,index,priceItem[dateList[index]],setPrice)"
                                                                   v-model="priceItem[dateList[index]]" :precision="2"
                                                                   :step="100"
                                                                   :min="0"></el-input-number>

                                                </div>
                                                <div v-if="dataForm.checkinType == 1">/ {{
                                                    item.prices.dateList[0][date.startDate1]
                                                  }}</div>
                                                <div v-else>/ {{ item.roomPrice }}</div>
                                              </span>
                                            </div>
                                          </td>
                                        </tr>
                                      </tbody>
                                    </table>
                                  </div>
                                </div>


                                <!-- 旧版-->
                                <!--                                <el-form label-width="100px" :inline="true" style="max-height: 300px !important;overflow-y: auto;">
                                  <el-form-item v-for="(item, index) in setPrice.prices.dateList" v-if="index < dataForm.days"
                                    :key="setPrice.roomId + ':' + index" :label="dateList[index]">
                                    <el-input-number style="width: 190px;" size="small" @change="changeTotal(item,index,item[dateList[index]],setPrice)"
                                      v-model="item[dateList[index]]" :precision="2" :step="100" :min="0"></el-input-number>
                                  </el-form-item>
                                </el-form> -->
                                <i class="el-icon-edit" slot="reference" style="cursor: pointer;"></i>
                              </el-popover>
                              <!-- <i class="el-icon-edit" slot="reference" @click="editRoomPrice(item)" style="cursor: pointer;"></i> -->
                              <span style="margin-left: 5px; margin-right: 5px;">/</span>
                              <span>门市价：</span>
                              <label v-if="dataForm.checkinType == 1">{{
                                  item.prices.dateList[0][date.startDate1]
                                }}</label>
                              <label v-else>{{ item.roomPrice }}</label>
                            </div>
                          </span>
                        </div>
                      </div>

                      <div style="margin-top: 10px;" v-if="item.prices.hoursMoney">
                        <div style="margin-bottom: 0px;" v-for="(people, peopleIndex) in item.peoples"
                             :key="peopleIndex">
                          <el-form-item class="in_block" label-width="0px" style="width: 13%;">
                            <el-input v-model="people.name" placeholder="姓名" size="small"></el-input>
                          </el-form-item>
                          <el-form-item class="in_block" label-width="0px" style="width: 10%;">
                            <el-select v-model="people.sex" placeholder="性别" size="small">
                              <el-option label="男" :value="1"></el-option>
                              <el-option label="女" :value="2"></el-option>
                            </el-select>
                          </el-form-item>
                          <el-form-item class="in_block" label-width="10px" style="width: 13%;">
                            <el-input v-model="people.tel" placeholder="手机号" size="small"></el-input>
                          </el-form-item>
                          <el-form-item class="in_block" label-width="0" style="width: 13%;">
                            <el-select v-model="people.type" placeholder="证件类型" size="small">
                              <!--            <el-option v-for="peopleType in options.peopleTypeOptions" :key="peopleType.value" :label="peopleType.label"
                                :value="peopleType.value"></el-option> -->
                              <el-option v-for="item in documenttypelist" :key="item.id" :label="item.label"
                                         :value="item.id">
                              </el-option>
                            </el-select>
                          </el-form-item>
                          <el-form-item class="in_block" label-width="10px" style="width: 13%;">
                            <el-input size="small" v-model="people.number" placeholder="证件号"></el-input>
                          </el-form-item>

                          <el-form-item class="in_block" label-width="10px" style="width: 13%;">
                            <el-input v-model="people.address" placeholder="地址" size="small"></el-input>
                          </el-form-item>
                          <el-button size="small" class="in_block" style="margin-left: 20px;"
                                     @click="readIdCard(peopleIndex,people)">读取身份证
                          </el-button>

                          <el-button size="small" class="in_block" v-if="peopleIndex != 0"
                                     @click="removePeople(item.peoples, people)">删除
                          </el-button>
                        </div>
                      </div>
                    </div>
                  </div>
                </div>
                <div v-else>
                  <div class="error_html">
                    <div class="text">点击上方按钮添加房间</div>
                  </div>
                </div>
              </div>
            </el-card>
            <el-card shadow="hover" style="">
              <div slot="header" class="clearfix"><span>收款录入</span></div>
              <div class="ant-card-body">
                <div class="title_day_price clear_float" style="padding: 0 0 10px;">
                  <div class="pull">
                    <div class="in_block">
                      <span>应收押金:</span>
                      <span>￥ {{ depositsetting.depositReceivable.toFixed(2) }}</span>
                    </div>
                    <div class="in_block">
                      <span>应收房费:</span>
                      <span>￥ {{ depositsetting.roomPrice.toFixed(2) }}</span>
                    </div>
                    <div class="in_block">
                      <span>押金自动录入:</span>
                      <span>
                        <el-switch @change="depositsettingSwithChange" v-model="depositsetting.depositsettingSwith"
                                   active-text="已开" class="switch" inactive-text="已关"></el-switch>
                      </span>
                    </div>
                    <div class="in_block">
                      <span>收款自动录入:</span>
                      <span>
                        <el-switch @change="depositsettingSwithChange2" v-model="depositsetting.depositShousettingSwith"
                                   active-text="已开" class="switch" inactive-text="已关"></el-switch>
                      </span>
                    </div>
                  </div>
                </div>
                <div class="title_day_price clear_float" style="padding: 0 0 10px;">
                  <div class="pull">
                    <div class="in_block">
                      <span>已收押金:</span>
                      <span>￥ {{ yajinPrice.toFixed(2) }}</span>
                    </div>
                    <div class="in_block">
                      <span>预收账款:</span>
                      <span>￥ {{ yushouPrice.toFixed(2) }}</span>
                    </div>
                    <div class="in_block">
                      <span>预授权:</span>
                      <span>￥ {{ authPrice.toFixed(2) }}</span>
                    </div>
                  </div>
                </div>
                <el-tabs v-model="paysActiveName" @tab-click="paysHandleClick">
                  <el-tab-pane label="收款" name="first">
                    <div v-for="(item, index) in nowpays" :key="index">
                      <el-tag type="danger" v-if="item.state == 1">押</el-tag>
                      <el-tag v-else>收</el-tag>
                      <el-form-item size="small" class="in_block" label-width="0">
                        <el-select v-model="item.nowType" @change="nowpaysChangeSelect(item)" placeholder="请选择"
                                   style="width: 150px;">
                          <el-option v-for="item in options.paysTypeOptions" :key="item.name" :label="item.name"
                                     :value="item.id"></el-option>
                        </el-select>
                      </el-form-item>
                      <el-form-item size="small" class="in_block" label-width="10px" style="width: 210px;">
                        <el-input-number size="small" @change="nowpaysChange" style="width: 190px;"
                                         v-model="item.payPrice"
                                         :precision="2" :step="100" :min="0"></el-input-number>
                        <!-- <el-input @change="nowpaysChange" v-model="item.payPrice" placeholder="￥ 0.00"></el-input> -->
                      </el-form-item>
                      <el-button size="small" class="in_block" v-if="index != 0" @click="remPaysItem(item)">删除
                      </el-button>
                      <el-button size="small" class="in_block" v-if="index == 0" @click="addPaysItem">添加收款
                      </el-button>
                      <el-button size="small" class="in_block" v-if="item.state == 1" @click="setState(item, 2)">
                        取消押金
                      </el-button>
                      <el-button size="small" class="in_block" v-else @click="setState(item, 1)">标记押金</el-button>
                    </div>
                  </el-tab-pane>
                  <el-tab-pane label="信用卡预授" name="second">
                    <div v-for="(item, index) in yunowpays" :key="index">
                      <el-form-item size="small" class="in_block" label-width="10px">
                        <el-input v-model="item.banksNumber" placeholder="银行卡号"></el-input>
                      </el-form-item>
                      <el-form-item size="small" class="in_block" label-width="10px">
                        <el-input v-model="item.referenceNumber" placeholder="预授权号"></el-input>
                      </el-form-item>
                      <el-form-item size="small" class="in_block" label-width="10px" style="width: 100px">
                        <el-input @change="yunowpaysChange" v-model="item.payPrice" placeholder="￥ 0.00"></el-input>
                      </el-form-item>
                      <el-button size="small" class="in_block" v-if="index != 0" @click="remyuPaysItem(item)">删除
                      </el-button>
                      <el-button size="small" class="in_block" v-if="index == 0" @click="addyuPaysItem">添加收款
                      </el-button>
                    </div>
                  </el-tab-pane>
                </el-tabs>
              </div>
            </el-card>
          </el-col>
        </el-row>
        <div class="ant-layout-footer">
          <!-- <el-button @click="visible = false">{{ $t('Common.Cancel') }}</el-button> -->
          <el-checkbox v-model="printDengjiDan" style="margin-right: 10px;width: 150px;">打印入住登记单</el-checkbox>
          <el-button type="danger" @click="dataFormSubmit">入 住</el-button>
        </div>
      </el-form>


      <el-dialog title="选择协议" :visible.sync="showagreement" v-if="showagreement" :append-to-body="true">
        <el-table :data="agreementdataList" border="" v-loading="dataListLoading" style="width: 100%;">
          <el-table-column type="selection" header-align="center" align="center" width="80"></el-table-column>
          <el-table-column prop="typeName" header-align="center" align="center" label="协议类型"></el-table-column>
          <el-table-column prop="name" header-align="center" align="center" label="协议主题"></el-table-column>
          <!--        	<el-table-column prop="khSigning" header-align="center" align="center" label="客户签约人"></el-table-column>
        	<el-table-column prop="bsSigning" header-align="center" align="center" label="本司签约人"></el-table-column> -->
          <el-table-column prop="no" header-align="center" align="center" label="协议单号"></el-table-column>
          <el-table-column prop="qyTime" header-align="center" align="center" label="签约时间"></el-table-column>
          <el-table-column prop="discount" header-align="center" align="center" label="折扣值"></el-table-column>
          <!--    	<el-table-column prop="operation" header-align="center" align="center" label="操作人"></el-table-column>
        	<el-table-column prop="updateTime" header-align="center" align="center" label="更新时间"></el-table-column>
        	<el-table-column prop="a" header-align="center" align="center" label="协议房价">
        		<template slot-scope="scope">
        			<el-button type="primary" @click="agreedrate(scope.row)">协议房价</el-button>
        		</template>
        	</el-table-column> -->

          <el-table-column fixed="right" header-align="center" align="center" width="150" label="操作">
            <template slot-scope="scope">
              <el-button type="text" size="small" @click="updateAgerembyxieyi(scope.row)">选择</el-button>
            </template>
          </el-table-column>
        </el-table>
        <el-pagination @size-change="sizeChangeHandle" @current-change="currentChangeHandle" :current-page="pageIndex"
                       :page-sizes="[10, 20, 50, 100]" :page-size="pageSize" :total="agreementpagesum"
                       layout="total, sizes, prev, pager, next, jumper"></el-pagination>
      </el-dialog>


      <el-dialog :visible="dialogshow" title="发门锁卡" :show-close="false" append-to-body class="famensuoka">
        <el-row>
          <el-col :span="12" style="border-right: 1px solid #ccc;text-align: center;padding-right:5px">
            <el-table :data="addRoomsList" @row-click="addroomclick" highlight-current-row>
              <el-table-column property="roomSignNum" label="房号" width="100"></el-table-column>
              <el-table-column label="姓名" width="100">
                <template slot-scope="scope">
                  <span>{{ scope.row.peoples[0].name }}</span>
                </template>
              </el-table-column>
              <el-table-column property="indexlength" label="写卡数"></el-table-column>
              <!--     <el-table-column property="address" label="状态"></el-table-column> -->
            </el-table>
            <el-tag>合计</el-tag>
            <el-tag>房数: {{ addRoomsList.length }}</el-tag>
            <el-tag>卡数: {{ kaindex }}</el-tag>
          </el-col>
          <el-col :span="12">
            <el-form ref="form" :model="form" label-width="100px">
              <el-form-item label="客人房号">
                <el-input :disabled="true" v-model="form.roomSignNum"></el-input>
              </el-form-item>
              <el-form-item label="失效时间">
                <el-col :lg="14">
                  <el-date-picker :disabled="true" v-model="date.stopDate1" type="date" placeholder="选择日期">
                  </el-date-picker>
                </el-col>
                <el-col :lg="10">
                  <el-time-select v-model="exitPoint" :disabled="true" :picker-options="{
                      start: '08:30',
                      step: '00:15',
                      end: '18:30'
                    }"
                                  placeholder="选择时间" style="min-width: 90px;padding-right: 0px;">
                  </el-time-select>
                </el-col>
              </el-form-item>
              <el-row style="margin-left: 100px;">
                <el-button @click="DoorNewCard(form)">制新卡</el-button>
                <el-button @click="DoorCopyCard(form)">复制卡</el-button>
                <el-button @click="DoorCancelCard(form)">注销</el-button>
              </el-row>
            </el-form>
          </el-col>
        </el-row>
        <div slot="footer" class="dialog-footer">
          <el-button type="primary" @click="kasave">确 定</el-button>
        </div>
      </el-dialog>


      <!-- 价格弹窗 -->
      <el-dialog title="价格修改" :visible.sync="priceVisible" :append-to-body="true">
        <el-form label-width="100px">
          <el-form-item v-for="(item, index) in setPrice.prices.dateList" v-if="index < dataForm.days"
                        :key="setPrice.roomId + ':' + index"
                        :label="dateList[index]">
            <el-input size="small" v-model="item[dateList[index]]" placeholder="金额"></el-input>
          </el-form-item>
          <!--        <el-form-item v-for="i in setPrice.prices.length - 6" :key="i" :label="dateList[i-1]">
              <el-input size="small" v-model="setPrice.prices[dateList[i-1]]"></el-input>
            </el-form-item> -->
        </el-form>
        <span slot="footer">
          <el-button @click="priceVisible = false">取消</el-button>
          <el-button type="primary" @click="dataFormSubmit()">{{ $t('Common.Confirm') }}</el-button>
        </span>
      </el-dialog>


      <el-dialog :close-on-click-modal="false" :close-on-press-escape="false" title="请扫描二维码"
                 :visible.sync="payVisible"
                 width="30%" append-to-body>
        <div v-loading="payLoding" element-loading-text="正在执行支付">
          <div style="  display: flex;
        justify-content: center;
        align-items: center;margin-bottom:10px">
            <img src="../../../../assets/img/barCode.jpg"/>
          </div>

          <div style="text-align:center">支持微信或支付宝条码支付</div>
          <div style="text-align:center">请用条码枪进行扫描</div>
          <span>
            <el-input v-model="auth_no" placeholder="请扫描二维码,支持微信支付宝" @keyup.enter.native="authClose"
                      ref="inputFocus"></el-input>
          </span>
        </div>
      </el-dialog>


      <!-- 选择房间-->
      <ruzhuFloorroomSelect v-if="ruzhuFloorroomSelectVisible" ref="ruzhuFloorroomSelect"
                            @refreshDataList="refreshRoomList"></ruzhuFloorroomSelect>
      <djrz80 v-show="false" id="djrz80" ref="djrz80" :note="this.printconfig.note"></djrz80>
      <djrz58 v-show="false" id="djrz58" ref="djrz58" :note="this.printconfig.note"></djrz58>
      <djrzA5 v-show="false" id="djrzA5" ref="djrzA5" :note="this.printconfig.note"></djrzA5>
    </div>
  </el-dialog>


</template>

<script>
import moment from 'moment';
import djrz80 from '../../../common/printtemplate/dengjiruzhu_80mm';
import djrz58 from '../../../common/printtemplate/dengjiruzhu_58mm';
import djrzA5 from '../../../common/printtemplate/dengjiruzhu_A5';
import ruzhuFloorroomSelect from './ruzhu-floorroom-select';
import {
  getLodop
} from '../../../../utils/lodop';

export default {
  data() {
    return {
      printconfig: {
        note: ''
      },
      editPriceSync: {
        floorRoomId: 0,
        piliang: false,
        price: '',
      },
      changePriceSync: [{
        floorRoomId: 0,
        piliang: false,
        price: 0,
      }],
      dialogshow: false,
      max: true,
      printDengjiDan: false,
      roomLoading: false,
      selectMenberFlag: false,
      selectSellerMenber: {},
      loading: false,
      yajinPrice: 0,
      documenttypelist: [],
      authPrice: 0,
      userly: [],
      yushouPrice: 0,
      newPrice: {},
      dataListLoading: false,
      setPrice: {
        prices: {
          dateList: []
        }
      },
      form: {},
      kaindex: 0,
      tmarketingList: [],
      ruzhuFloorroomSelectVisible: false,
      priceVisible: false,
      // 押金类型为现付（0AR帐1现金2储值卡3积分兑换4银行卡5支付宝6微信）
      options: {
        sellerMenberOp: [],
        housOptions: [],
        paysTypeOptions: [],
        peopleTypeOptions: [
          // 身份类型（0居民身份证1户口簿2军官证3警官证4士兵证5护照6其他）
          {
            label: '居民身份证',
            value: '0'
          },
          {
            label: '户口簿',
            value: '1'
          },
          {
            label: '军官证',
            value: '2'
          },
          {
            label: '警官证',
            value: '3'
          },
          {
            label: '士兵证',
            value: '4'
          },
          {
            label: '护照',
            value: '5'
          },
          {
            label: '其他',
            value: '6'
          }
        ]
      },
      nowpays: [{
        nowType: '',
        payPrice: '',
        state: 2
      }],
      yunowpays: [{
        banksNumber: '',
        referenceNumber: '',
        state: 2,
        payPrice: ''
      }],
      paysActiveName: 'first',
      // （0散客1会员2协议单位3中介）
      pickerOptions: {
        disabledDate(time) {
          return time.getTime() < Date.now();
        }
      },
      addRoomsList: [],
      zidingyiSwitch: false,
      ruzhuZhang: true,
      sourceTypeOptions: [{
        label: '散客',
        value: 0
      },
        {
          label: '会员',
          value: 1
        },
        {
          label: '协议单位',
          value: 2
        },
        {
          label: '中介',
          value: 3
        }
      ],
      guaranteeTypeOptions: [{
        label: '无担保',
        value: 0
      },
        {
          label: '有担保',
          value: 1
        },
        {
          label: 'OTA担保',
          value: 2
        }
      ],
      date: {
        startDate1: moment().format('YYYY-MM-DD'),
        startDate2: moment().format('HH:mm'),
        stopDate1: moment()
          .add(1, 'days')
          .format('YYYY-MM-DD'),
        stopDate2: '12:00'
      },
      roomDayRule: {},
      housOptions: [],
      item: {},
      agreementdataList: [],
      showagreement: false,
      reserInit: false,
      schemelist: [],
      agreementpagesum: 0,
      payInterfaceConfig: {}, //支付
      visible: false,
      dateList: [],
      payLoding: false,
      dataForm: {
        sa: '',
        housId: '',
        sellerId: '',
        userId: '',
        schemeId: '',
        memberId: '',
        checkinType: 0,
        arrivalsTime: '',
        predissociationTime: '',
        days: 1,
        agreemCustomerId: '',
        sourceType: 0,
        sourceName: '',
        sourceNames: '',
        activityId: '',
        guaranteeType: 0,
        saleId: '',
        externalNo: '',
        remarks: '',
        roomsNum: 0,
        roomsDays: 1,
        totalPrice: 0.0,
        creatTime: '',
        zc: 0,
        sourceAgreenid: '',
        agreemId: ''
      },
      sid: '',
      agreemxyrows: {},
      dataRule: {
        sellerId: [{
          required: true,
          message: '商家不能为空',
          trigger: 'blur'
        }],
        userId: [{
          required: true,
          message: '操作人不能为空',
          trigger: 'blur'
        }],
        memberId: [{
          required: true,
          message: '会员不能为空',
          trigger: 'blur'
        }],
        checkinType: [{
          required: true,
          message: '入住类型（0全天1时租2自用3免费）不能为空',
          trigger: 'blur'
        }],
        arrivalsTime: [{
          required: true,
          message: '预抵时间不能为空',
          trigger: 'blur'
        }],
        predissociationTime: [{
          required: true,
          message: '预离时间不能为空',
          trigger: 'blur'
        }],
        days: [{
          required: true,
          message: '天数不能为空',
          trigger: 'blur'
        }],
        sourceType: [{
          required: true,
          message: '客源（0散客1会员2协议单位3中介）不能为空',
          trigger: 'blur'
        }],
        sourceName: [{
          required: true,
          message: '客源标记不能为空',
          trigger: 'blur'
        }],
        activityId: [{
          required: true,
          message: '市场活动不能为空',
          trigger: 'blur'
        }],
        guaranteeType: [{
          required: true,
          message: '担保方式（0无担保1担保2OTA担保）不能为空',
          trigger: 'blur'
        }],
        saleId: [{
          required: true,
          message: '销售不能为空',
          trigger: 'blur'
        }],
        externalNo: [{
          required: true,
          message: '外部单号不能为空',
          trigger: 'blur'
        }],
        remarks: [{
          required: true,
          message: '备注不能为空',
          trigger: 'blur'
        }],
        roomsNum: [{
          required: true,
          message: '房间数不能为空',
          trigger: 'blur'
        }],
        roomsDays: [{
          required: true,
          message: '占房天数不能为空',
          trigger: 'blur'
        }],
        totalPrice: [{
          required: true,
          message: '总价不能为空',
          trigger: 'blur'
        }],
        peopleName: [{
          required: true,
          message: '姓名不能为空',
          trigger: 'blur'
        }],
        peopleTel: [{
          required: true,
          message: '手机号不能为空',
          trigger: 'blur'
        }],
        peopleType: [{
          required: true,
          message: '身份类型不能为空',
          trigger: 'blur'
        }],
        peopleNumber: [{
          required: true,
          message: '身份证号不能为空',
          trigger: 'blur'
        }],
        creatTime: [{
          required: true,
          message: '创建时间不能为空',
          trigger: 'blur'
        }],

      },
      doorLockParams: {
        RoomNumber: "",
        StartDate: "",
        EndDate: "",
        OpeartorType: "",
        CardID: "",
        skr: "",
        sfz: "",
        CardNum: ""
      },
      itemso: {},
      exitPoint: '',
      dataFormsa: {
        skTime: '',
        zkUser: '',
        roomNum: '',
        kaNo: '',
        creatUserId: '',
        endTime: '',
        ckSfz: '',
        operation: '',
        creatTime: '',
        floorCengId: '',
        floorId: ''
      },
      agreementFrom: {
        name: undefined,
        limit: undefined,
        page: undefined,
        agreementId: undefined
      },
      pageIndex: 1,
      pageSize: 10,
      totalPage: 0,
      depositsetting: {
        entity: {},
        depositsettingSwith: true,
        depositShousettingSwith: true,
        depositReceivable: 0,
        roomPrice: 0
      },
      istrues: 0,
      reindex: '',
      rename: '',
      retel: '',
      recha: '',
      reyshouk: '',
      reweijs: '',
      reyjs: '',
      dataListLoadings: false,
      listrestaurants: [],
      restaurants: [],
      initList: [],
      listrestaurantsa: [],
      restaurantsquert: [],
      payInterfaceConfig: {}, //支付
      payVisible: false,
      auth_no: '',
      sbMoney: 0,
      timer: null,
    };
  },
  components: {
    ruzhuFloorroomSelect,
    djrz80,
    djrz58,
    djrzA5
  },
  methods: {
    async init(list) {
      Object.assign(this.$data, this.$options.data());
      this.getDepositsetting();
      console.log(this.$cookie.get('printDengjiDan'))
      if (this.$cookie.get('printDengjiDan') != null) {
        if (this.$cookie.get('printDengjiDan') == 1) {
          this.printDengjiDan = true
        } else {
          this.printDengjiDan = false
        }
      }
      this.initList = list
      this.itemso = list[0];
      this.loadPrintConfig();
      this.getroomhours();
      this.getPayInterface();
      this.getdatehour();
      this.getDataListtmark();
      this.getagreementType('document_type');
      await this.getagreementType('userly');
      this.getList();
      this.getPayTypes();
      this.getselectone();
      this.visible = true;

    },
    changeRoomPrice(item, setPrice) {
      console.log(this.newPrice)
      console.log(item)
      console.log(setPrice)
      this.changeTotalPrice(this.addRoomsList)
    },
    depositsettingSwithChange() {
      this.$http({
        url: this.$http.adornUrl(`/hotel/thoteldepositsetting/${!this.depositsetting.entity.id ? 'save' : 'update'}`),
        method: 'post',
        data: this.$http.adornData({
          'id': this.depositsetting.entity.id || undefined,
          'depositSettingSwith': this.depositsetting.depositsettingSwith ? 1 : 2,
        })
      }).then(({
                 data
               }) => {

      })
    },
    depositsettingSwithChange2() {
      this.$http({
        url: this.$http.adornUrl(`/hotel/thoteldepositsetting/${!this.depositsetting.entity.id ? 'save' : 'update'}`),
        method: 'post',
        data: this.$http.adornData({
          'id': this.depositsetting.entity.id || undefined,
          'depositShousettingSwith': this.depositsetting.depositShousettingSwith ? 1 : 2,
        })
      }).then(({
                 data
               }) => {

      })
    },
    getDepositsetting() {
      this.$http({
        url: this.$http.adornUrl(`/hotel/thoteldepositsetting/seller`),
        method: 'get',
        params: this.$http.adornParams()
      }).then(({
                 data
               }) => {
        if (data && data.code === 0) {
          this.depositsetting.entity = data.entity
          this.depositsetting.depositsettingSwith = data.entity.depositSettingSwith == 1 ? true : false
          this.depositsetting.depositShousettingSwith = data.entity.depositShousettingSwith == 1 ? true : false
        }
      })
    },
    getDataListtmark() {
      this.$http({
        url: this.$http.adornUrl('/hotel/tmarketingmanagement/list'),
        method: 'get',
        params: this.$http.adornParams({
          'page': 1,
          'limit': 9999,
          'status': '1',
        })
      }).then(({
                 data
               }) => {
        if (data && data.code === 0) {
          this.tmarketingList = data.page.list
        } else {
          this.tmarketingList = []
        }
      })
    },
    handleSelect() {
      if (this.dataForm.schemeId == '') {
        if (this.dataForm.sourceType == 2) {
          this.getxieyimoney(this.addRoomsList, this.agreemxyrows.id);
        } else {
          this.reqRoomPrice(this.addRoomsList);
        }
      }
      this.changescheme(this.dataForm.schemeId);
    },
    async changeTotal(item, index, val, setPrice) {
      if (val == '') {
        this.setPrice.prices.dateList[index][this.dateList[index]] = 0;
        val = 0;
      }
      var today = false
      if (this.dateList[index] == moment().format('YYYY-MM-DD')) {
        today = true
      }
      var floorRoomId = this.newPrice.id
      var floorRoomList = await this.changePriceSync.filter(item => item.floorRoomId == floorRoomId)
      if (floorRoomList.length == 0) {
        this.changePriceSync.push({
          floorRoomId: floorRoomId,
          piliang: false,
          price: 0,
          ...item
        })
      } else {
        var entity = floorRoomList[0]
        entity[this.dateList[index]] = val
      }
      this.changeTotalPrice(this.addRoomsList);
    },
    async getGreenPriceList(priceEntity2) {
      var arr = [];
      for (var key in priceEntity2) {
        var entity = {};
        entity[key] = priceEntity2[key]
        arr.push(entity)
      }
      return arr;
    },
    async getGreenPriceList2(priceEntity2, dateList) {
      var today = moment().format('YYYY-MM-DD')
      dateList.forEach(async (item, index) => {
        for (var key in item) {
          if (undefined != priceEntity2[key]) {
            item[key] = priceEntity2[key]
          } else {
            // if (key != today && undefined != priceEntity2[today]) {
            //   item[key] = priceEntity2[today]
            // }
            if (priceEntity2.price) {
              if (priceEntity2.piliang) {
                item[key] = priceEntity2.price
              }
            }
          }
        }
      })
      return dateList;
    },
    querySearchAsync(value) {
      this.listrestaurantsa = [];
      var restaurants = this.restaurantsquert;
      for (var i = 0; i < restaurants.length; i++) {
        var demo = restaurants[i].label;
        if (demo.indexOf(value) != -1) {
          this.dataListLoadings = true;
          this.listrestaurantsa.push(restaurants[i]);
        }
      }
      if (value == '') {
        this.listrestaurantsa = this.restaurantsquert;
      }
      this.dataListLoadings = false;
    },
    changescheme(item) {
      var rooids = [];
      this.addRoomsList.forEach((item, index) => {
        rooids.push(item.roomId)
      })
      this.$http({
        url: this.$http.adornUrl('/hotel/thotelfloorschemeroomjl/queryone'),
        method: 'get',
        params: this.$http.adornParams({
          page: 1,
          limit: 999,
          schemeId: item,
          datas: this.date.startDate1,
          roomlist: rooids.join(","),
          day: this.dataForm.days
        })
      }).then(({
                 data
               }) => {
        if (data && data.code === 0) {
          console.log("房价方案", data)
          this.addRoomsList.forEach((item, index) => {
            var arr = item.prices.dateList;
            for (var s = 0; s < data.page.jllist.length; s++) {
              if (parseInt(data.page.jllist[s].roomId) == item.roomId) {
                for (var i = 0; i < this.dataForm.days; i++) {
                  item.prices[this.dateList[i]] = data.page.jllist[s].list[i][this.dateList[i]];
                  arr[i][this.dateList[i]] = data.page.jllist[s].list[i][this.dateList[i]];
                }
              }
            }
          });

          this.$nextTick(() => {
            const _that = this
            setTimeout(() => {
              _that.changeTotalPrice(_that.addRoomsList);
            }, 10)
          })
        } else {
          this.schemelist = [];
        }
      });

    },
    getschemelist() {
      this.$http({
        url: this.$http.adornUrl('/hotel/thotelfloorscheme/listArray'),
        method: 'get',
        params: this.$http.adornParams({
          page: 1,
          limit: 999,
          type: this.dataForm.sourceAgreenid
        })
      }).then(({
                 data
               }) => {
        if (data && data.code === 0) {
          this.restaurantsquert = data.page.list;
          this.listrestaurantsa = data.page.list;
        } else {
          this.restaurantsquert = [];
        }
      });

    },
    async piliangChengPriceHead(val) {
      if ('' == val) {
        this.editPriceSync.piliang = false;
      } else {
        this.editPriceSync.piliang = true;
        var dateList = this.setPrice.prices.dateList
        dateList.forEach((item, index) => {
          for (var key in item) {
            item[key] = val
            this.setPrice.prices[key] = val
          }
        })
        var floorRoomList = await this.changePriceSync.filter(sync => sync.floorRoomId == this.editPriceSync.floorRoomId)
        if (floorRoomList.length > 0) {
          floorRoomList[0] = {}
          floorRoomList[0] = {
            floorRoomId: this.editPriceSync.floorRoomId,
            piliang: this.editPriceSync.piliang,
            price: this.editPriceSync.price,
          }
          console.log("floorRoomList[0]", floorRoomList[0])
        }
        this.changeTotalPrice(this.addRoomsList);
      }
    },
    async editRoomPrice(item) {
      var floorRoomList = await this.changePriceSync.filter(sync => sync.floorRoomId == item.id)
      if (floorRoomList.length == 0) {
        var entity = {
          floorRoomId: item.id,
          piliang: false,
          price: 0,
          ...item
        }
        this.changePriceSync.push(entity)
        this.editPriceSync = entity
      } else {
        var entity = floorRoomList[0]
        this.editPriceSync = entity
      }
      this.setPrice = {};
      // this.priceVisible = true;
      this.newPrice = item;
      this.setPrice = {
        prices: {
          ...item.prices
        }
      };
    },
    //获取支付方式
    getPayTypes() {
      this.$http({
        url: this.$http.adornUrl('/hotel/thotelfloorroompaytype/list'),
        method: 'get',
        params: this.$http.adornParams({
          page: 1,
          limit: 999,
          isDeposit: 1,
          state: 1,
        })
      }).then(({
                 data
               }) => {
        if (data && data.code === 0) {
          this.options.paysTypeOptions = data.page.list;
          this.nowpays[0].nowType = this.options.paysTypeOptions[0].id
        } else {
          this.options.paysTypeOptions = [];
        }
      });
    },
    updateAgerembyxieyi(row) {
      console.log("协议放假", row)

      this.agreemxyrows = row;

      this.getxieyimoney(this.addRoomsList, row.id);

      this.dataForm.agreemCustomerId = row.id;
      this.showagreement = false;
    },
    getxieyimoney(addRoomsList, id) {
      var rooids = '';
      for (var i = 0; i < this.addRoomsList.length; i++) {
        rooids += this.addRoomsList[i].roomId + ",";
      }
      if (this.dataForm.schemeId != '') {
        this.changescheme(this.dataForm.schemeId);

      } else {
        this.$http({
          url: this.$http.adornUrl('/hotel/tagreementpricelist/getxieyimoney'),
          method: 'get',
          params: this.$http.adornParams({
            floorRoomId: rooids,
            customerId: id,
          })

        }).then(({
                   data
                 }) => {
          if (data && data.code === 0) {
            var money = 0;
            this.addRoomsList.forEach((item, index) => {
              var prices = item.prices
              var arr = item.prices.dateList;
              for (var s = 0; s < data.page.length; s++) {
                if (data.page[s].floorRoomId == item.roomId) {

                  console.log("协议房价房型信息", data.page[s])

                  this.dataForm.zc = data.page[s].zcnumber;

                  for (var i = 0; i < this.dataForm.days; i++) {
                    arr[i][this.dateList[i]] = data.page[s].xymoney;
                    prices[this.dateList[i]] = data.page[s].xymoney;
                    money += data.page[s].xymoney;
                  }
                }
              }
            });
            this.dataForm.totalPrice = money;

            this.changeTotalPrice(this.addRoomsList);
          } else {
            this.dataForm.totalPrice = 0;
          }
        });
      }

    },
    sizeChangeHandle(val) {
      this.pageSize = val;
      this.pageIndex = 1;
      this.getagreementByxieyi();
    },
    // 当前页
    currentChangeHandle(val) {
      this.pageIndex = val;
      this.getagreementByxieyi();
    },
    getagreementByxieyi() {
      this.agreementFrom.agreementId = this.dataForm.agreemId;
      this.agreementFrom.limit = this.pageSize;
      this.agreementFrom.page = this.pageIndex;
      this.$http({
        url: this.$http.adornUrl('/hotel/agreement-customer/list'),
        method: 'get',
        params: this.agreementFrom
      }).then(({
                 data
               }) => {
        if (data && data.code === 0) {

          this.agreementdataList = data.page.list;
          this.agreementpagesum = data.page.sum;
          this.showagreement = true;
          this.dataListLoading = false;
        } else {
          this.agreementdataList = [];
          this.agreementpagesum = 0;
        }
        this.dataListLoading = false;
      });

    },

    sellerxieyiChange(value) {

      this.listrestaurants = [];
      console.log(value);
      var restaurants = this.restaurants;
      for (var i = 0; i < this.restaurants.length; i++) {
        var demo = restaurants[i].values;
        if (demo.indexOf(value) != -1) {
          this.dataListLoading = true;
          this.dataForm.agreemId = restaurants[i].id
          this.getagreementByxieyi();
          this.rename = this.restaurants[i].name;
          this.retel = this.restaurants[i].tel;
          this.recha = this.restaurants[i].cha;
          this.reyshouk = this.restaurants[i].yshouk;
          this.reweijs = this.restaurants[i].wejies;
          this.reyjs = this.restaurants[i].yjs;
          this.listrestaurants.push(restaurants[i]);
        }
      }
    },
    // checkinTypeChange(val) {
    //   if (val == 0 || val == 2 || val == 3) {
    //     this.refreshRoomList(this.addRoomsList);
    //   }
    //   if (val == 1) {
    //     if (!this.dataForm.housId) {
    //       if (this.options.housOptions.length > 0) {
    //         this.dataForm.housId = this.options.housOptions[0].id;
    //       } else {
    //         this.$message.error('请设置钟点房计费规则');
    //       }
    //     }
    //     this.reqRoomHoursPrice(this.addRoomsList);
    //   }
    // },
    //获取钟点房规则
    getroomhours() {
      this.$http({
        url: this.$http.adornUrl('/hotel/thotelfloorroomhours/list'),
        method: 'get',
        params: this.$http.adornParams({
          page: 1,
          limit: 999
        })
      }).then(({
                 data
               }) => {
        if (data && data.code === 0) {
          this.options.housOptions = data.page.list;
        } else {
          this.options.housOptions = [];
        }
      });
    },
    addpeople(item, index) {
      if (this.documenttypelist.length > 0) {
        item.peoples.push({
          name: '',
          tel: '',
          number: '',
          sex: 1,
          type: this.documenttypelist[0].id,
          address: ''
        });
      } else {
        item.peoples.push({
          name: '',
          tel: '',
          number: '',
          sex: 1,
          type: '',
          address: ''
        });
      }
    },
    removeRoom(item, index) {
      this.addRoomsList.splice(this.addRoomsList.indexOf(item), 1);
      this.$nextTick(() => {
        this.checkinTypeChange(this.dataForm.checkinType);
      });
    },
    removePeople(list, item) {
      list.splice(list.indexOf(item), 1);
    },
    refreshRoomList(val) {
      console.log(val);
      val.forEach(item => {
        if (item.peoples.length == 0) {
          if (this.documenttypelist.length > 0) {
            item.peoples.push({
              name: '',
              tel: '',
              number: '',
              sex: 1,
              type: this.documenttypelist[0].id,
              address: ''
            });
          } else {
            item.peoples.push({
              name: '',
              tel: '',
              number: '',
              sex: 1,
              type: '',
              address: ''
            });
          }
        }
      });
      this.addRoomsList = val;
      //改价格
      this.reqRoomPrice(this.addRoomsList);

    },
    nowpaysChange() {
      this.yajinPrice = 0;
      this.yushouPrice = 0;
      this.authPrice = 0;
      this.nowpays.forEach(item => {
        if (item.state == 1) {
          this.yajinPrice += parseFloat(item.payPrice ? item.payPrice : 0);
        } else {
          this.yushouPrice += parseFloat(item.payPrice ? item.payPrice : 0);
        }
      });
    },

    checkinTypeChange(val) {
      if (val == 0 || val == 2 || val == 3) {
        this.refreshRoomList(this.addRoomsList);
      }
      if (val == 1) {
        if (!this.dataForm.housId) {
          if (this.options.housOptions.length > 0) {
            this.dataForm.housId = this.options.housOptions[0].id;
          } else {
            this.$message.error('请设置钟点房计费规则');
          }
        }
        this.reqRoomHoursPrice(this.addRoomsList);
      }
    },

    reqRoomHoursPrice(arr) {
      var idArr = [];
      arr.forEach((item, index) => {
        idArr.push(item.roomId);
      });
      var ids = idArr.join(',');
      this.$http({
        url: this.$http.adornUrl(`/hotel/thotelfloorroomhours/room_hours_money`),
        method: 'get',
        params: this.$http.adornParams({
          startDate: this.date.startDate1,
          endDate: moment()
            .add(1, 'days')
            .format('YYYY-MM-DD'),
          hoursId: this.dataForm.housId,
          roomIds: ids
        })
      }).then(({
                 data
               }) => {
        if (data && data.code === 0) {
          console.log(data);
          for (var i = 0; i < this.addRoomsList.length; i++) {
            data.data.forEach((item, index) => {
              if (item.roomId == this.addRoomsList[i].roomId) {
                let _obj = JSON.stringify(item),
                  objClone = JSON.parse(_obj);
                this.addRoomsList[i].prices = objClone;
                console.log(item);
              }
            });
          }
          this.changeTotalHoursPrice(this.addRoomsList);
        } else {
          this.$message.error(data.msg);
        }
      });
    },
    hoursChange(hoursId) {
      console.log(hoursId);
      this.reqRoomHoursPrice(this.addRoomsList);
    },
    yunowpaysChange() {
      this.yajinPrice = 0;
      this.yushouPrice = 0;
      this.authPrice = 0;
      this.yunowpays.forEach(item => {
        this.authPrice += parseFloat(item.payPrice ? item.payPrice : 0);
      });
    },
    setState(item, state) {
      item.state = state;
      this.nowpaysChange();
      this.$forceUpdate();
    },
    addPaysItem() {
      this.nowpays.push({
        nowType: '',
        payPrice: '',
        state: 2
      });
    },
    remoteMethod(query) {
      if (query !== '') {
        this.loading = true;
        this.$http({
          url: this.$http.adornUrl('/hotel/hotelmemberleveldetail/shareList'),
          method: 'get',
          params: this.$http.adornParams({
            page: 1,
            limit: 999,
            share: 1,
            ruzhuQuery: query
          })
        }).then(({
                   data
                 }) => {
          if (data && data.code === 0) {
            console.log(data);
            this.options.sellerMenberOp = data.page.records;
          } else {
            this.options.sellerMenberOp = [];
          }
          this.loading = false;
        });
      } else {
        this.options.sellerMenberOp = [];
      }
    },
    sellerMenberChange(value) {
      console.log(value);
      var arr = this.options.sellerMenberOp.filter(item => item.id == value);
      this.selectSellerMenber = arr[0];
      this.selectMenberFlag = true;
      if (this.addRoomsList.length > 0) {
        this.changePriceSync = [{
          floorRoomId: 0,
          piliang: false,
          price: 0,
        }];
        this.reqRoomPrice(this.addRoomsList);
      }
      //修改第一个同住为会员信息
      if (this.addRoomsList.length > 0) {
        var floorroom = this.addRoomsList[0]
        var people = floorroom.peoples[0]
        people.name = arr[0].name
        people.tel = arr[0].tel
        people.sex = arr[0].gender == '1' ? 1 : 2
        people.number = arr[0].certificateNo
      }
    },
    addyuPaysItem() {
      this.yunowpays.push({
        banksNumber: '',
        referenceNumber: '',
        state: 2,
        payPrice: ''
      });
    },
    remPaysItem(item) {
      this.nowpays.splice(this.nowpays.indexOf(item), 1);
    },
    remyuPaysItem(item) {
      this.yunowpays.splice(this.yunowpays.indexOf(item), 1);
    },
    paysHandleClick(tab, event) {
      console.log(tab.index);
      const index = tab.index;
      this.yajinPrice = 0;
      this.yushouPrice = 0;
      //切换到现付收款
      if (index == 0) {
        this.nowpaysChange();
        //切换到预付款
      } else {
        this.yunowpaysChange();
      }
      console.log(tab, event);
    },
    addRoomsBtn() {
      this.ruzhuFloorroomSelectVisible = true;
      this.$nextTick(() => {
        this.$refs.ruzhuFloorroomSelect.init(this.addRoomsList);
      });
    },

    daysChange(val) {
      console.log(val);
      this.date.stopDate1 = moment()
        .add(val, 'days')
        .format('YYYY-MM-DD');
      this.dataForm.roomsDays = val;
      this.$nextTick(() => {
        this.getdateList();
        this.refreshRoomList(this.addRoomsList);

      });


    },

    async getagreementType(type) {
      this.$http({
        url: this.$http.adornUrl('/hotel/thotelagreementtype/list'),
        method: 'get',
        params: this.$http.adornParams({
          page: 1,
          limit: 999,
          type: type
        })
      }).then(({
                 data
               }) => {
        if (data.code != 0) {
          this.$message.error(data.msg);
        }
        if ("userly" == type) {
          this.userly = data.page.list;
          if (this.userly.length == 0) {
            this.$message({
              showClose: true,
              message: '请设置客人来源',
              type: 'error'
            });
          } else {
            this.dataForm.sourceAgreenid = this.userly[0].id;
            this.getschemelist();
          }
        } else {
          this.documenttypelist = data.page.list;


          this.$nextTick(() => {

            if (this.documenttypelist.length > 0) {
              var arr = this.initList.map(item => ({
                ...item,
                peoples: [{
                  name: '',
                  tel: '',
                  number: '',
                  type: this.documenttypelist[0].id,
                  sex: 1,
                  address: ''
                }]
              }));
            } else {
              var arr = this.initList.map(item => ({
                ...item,
                peoples: [{
                  name: '',
                  tel: '',
                  number: '',
                  type: '',
                  sex: 1,
                  address: ''
                }]
              }));
            }
            this.getdateList();
            this.refreshRoomList(arr);
          });

        }
      });
    },
    // sellerMenberChange(value) {
    //   console.log(value);
    //   var arr = this.options.sellerMenberOp.filter(item => item.id == value);
    //   this.selectSellerMenber = arr[0];
    //   this.selectMenberFlag = true;
    //   if (this.addRoomsList.length > 0) {
    //     this.reqRoomPrice(this.addRoomsList);
    //   }
    // },
    getList() {

      this.$http({
        url: this.$http.adornUrl('/hotel/agreement/shareGetDropDown'),
        method: 'get',
        params: this.$http.adornParams({
          share: 3
        })
      }).then(({
                 data
               }) => {

        this.restaurants = data.list;
        this.listrestaurants = data.list;
      });

    },
    getdatehour() {
      this.$http({
        url: this.$http.adornUrl(`/hotel/thotelfloorroomdayrule/seller`),
        method: 'get',
        params: this.$http.adornParams()
      }).then(({
                 data
               }) => {
        if (data && data.code === 0) {
          this.roomDayRule = data.tHotelFloorRoomDayRule
          this.exitPoint = data.tHotelFloorRoomDayRule.exitPoint;
          this.$nextTick(() => {
            console.log("开始时间", this.date.startDate2)
            var startNum1 = parseInt(this.date.startDate2.split(":")[0])
            var startNum2 = parseInt(this.date.startDate2.split(":")[1])
            console.log("小时", startNum1)
            console.log("分钟", startNum2)
            console.log("this.roomDayRule", this.roomDayRule)
            var rule1 = parseInt(this.roomDayRule.afterPointNext.split(":")[0])
            var rule2 = parseInt(this.roomDayRule.afterPointNext.split(":")[1])
            console.log("小时", rule1)
            console.log("分钟", rule2)
            console.log("计算小时", startNum1 <= rule1)
            console.log("计算分钟", startNum2 < rule2)
            console.log("时间flag", startNum1 <= rule1 && startNum2 < rule2)
            if (startNum1 <= rule1 && startNum2 < rule2) {
              this.date.stopDate1 = moment().format('YYYY-MM-DD');
            }
          })
        }
      });
    },
    inquiryReserInit(item) {
      this.$confirm(`此房间有预定且时间冲突是否确定办理入住？`, '提示', {
        confirmButtonText: '是',
        cancelButtonText: '否',
        closeOnClickModal: false,
        closeOnPressEscape: false,
        distinguishCancelAndClose: true,
        type: 'warning'
      }).then(() => {
        this.reserInit = true;
        this.dataFormSubmit();
      }).catch(() => {
        this.reserInit = false;
      });
    },
    getselectone() {
      this.$http({
        url: this.$http.adornUrl(`/hotel/tmarketingmanagement/one`),
        method: 'get',
        params: this.$http.adornParams({})
      }).then(({
                 data
               }) => {
        if (data && data.code === 0) {
          if (data.page != null && data.page != '') {
            this.dataForm.saleId = parseInt(data.page);
          }
        }

      })
    },
    //加载日期
    getdateList() {
      this.dateList = [];
      for (var i = 0; i <= this.dataForm.days; i++) {
        this.dateList.push(
          moment()
            .add(i, 'days')
            .format('YYYY-MM-DD')
        );
      }
    },
    async reqRoomPrice(arr) {
      this.roomLoading = true
      var idArr = [];
      arr.forEach((item, index) => {
        idArr.push(item.roomId);
      });
      var ids = idArr.join(',');
      this.$http({
        url: this.$http.adornUrl(`/hotel/hotelroomprice/list3`),
        method: 'get',
        params: this.$http.adornParams({
          startDate: this.date.startDate1,
          endDate: this.date.stopDate1,
          ids: ids
        })
      }).then(({
                 data
               }) => {
        if (data && data.code === 0) {

          console.log(data);
          for (var i = 0; i < this.addRoomsList.length; i++) {
            data.data.dataList.forEach((item, index) => {
              if (item.roomId == this.addRoomsList[i].roomId) {
                let _obj = JSON.stringify(item),
                  objClone = JSON.parse(_obj);
                this.addRoomsList[i].prices = objClone;
                console.log(item);
              }
            });
          }

          //免费自用
          if (this.dataForm.checkinType == 2 || this.dataForm.checkinType == 3) {
            this.addRoomsList.forEach((item, index) => {
              var arr = item.prices.dateList;
              for (var i = 0; i < this.dataForm.days; i++) {
                arr[i][this.dateList[i]] = 0
              }
            });
          } else {
            //会员折扣价
            if (this.selectMenberFlag) {
              this.addRoomsList.forEach((item, index) => {
                var arr = item.prices.dateList;
                for (var i = 0; i < this.dataForm.days; i++) {
                  arr[i][this.dateList[i]] = (parseFloat(arr[i][this.dateList[i]]) * parseFloat(this.selectSellerMenber
                    .discount)).toFixed(2)
                }
              });
            }

          }

          //查询修改记录
          this.changePriceSync.forEach(async (changePriceEntity, index) => {
            console.log(changePriceEntity)
            var floorRoomList = await this.addRoomsList.filter(item => item.id == changePriceEntity.floorRoomId);
            if (floorRoomList.length > 0) {
              var priceEntity2 = JSON.parse(JSON.stringify(changePriceEntity))
              delete priceEntity2.floorRoomId;
              var entity = floorRoomList[0]
              var prices = entity.prices
              console.log(prices)
              // var dateList = await this.getGreenPriceList(priceEntity2)
              var dateList2 = await this.getGreenPriceList2(priceEntity2, prices.dateList)
              prices = {
                ...prices,
                ...priceEntity2,
                dateList: dateList2
              }
              floorRoomList[0].prices = prices
              console.log(entity)
              console.log(prices)
            }
          })

          this.$nextTick(() => {
            const _that = this
            setTimeout(() => {
              if (_that.dataForm.schemeId != '') {
                _that.changescheme(_that.dataForm.schemeId)
              } else if (_that.agreemxyrows.id) {
                _that.getxieyimoney(_that.addRoomsList, _that.agreemxyrows.id);
              } else {
                _that.changeTotalPrice(_that.addRoomsList);
              }
            }, 10)
          })

        } else {
          this.$message.error(data.msg);
        }
        this.roomLoading = false
      });

    },
    //计算总金额
    async changeTotalPrice(list) {
      var money = 0;
      var money2 = 0;
      if (this.dataForm.checkinType == 0) {
        list.forEach((item, index) => {
          var arr = item.prices.dateList;
          for (var i = 0; i < this.dataForm.days; i++) {
            if (i == 0) {
              money2 += parseFloat(arr[i][this.dateList[i]]);
            }
            money += parseFloat(arr[i][this.dateList[i]]);
          }
        });
      }
      this.dataForm.totalPrice = money;

      //处理押金
      this.depositsetting.depositReceivable = 0
      if (this.depositsetting.entity.balanceType == 0) {
        this.depositsetting.depositReceivable = money2 * this.depositsetting.entity.balanceTypeMultiple
      } else if (this.depositsetting.entity.balanceType == 1) {
        this.depositsetting.depositReceivable = money2 + this.depositsetting.entity.balanceTypeMoney
      } else if (this.depositsetting.entity.balanceType == 2) {
        this.depositsetting.depositReceivable = this.depositsetting.entity.balanceTypeMoney + 0
      }
      //处理房费
      this.depositsetting.roomPrice = 0
      this.depositsetting.roomPrice = money + 0

      //全开
      if (this.depositsetting.depositsettingSwith && this.depositsetting.depositShousettingSwith) {
        var paysLength = this.nowpays.length
        if (paysLength <= 1) {
          this.nowpays = []
          this.nowpays.push({
            nowType: this.options.paysTypeOptions[0].id,
            payPrice: (this.depositsetting.depositReceivable + 0).toFixed(2),
            state: 1
          })
          this.nowpays.push({
            nowType: this.options.paysTypeOptions[0].id,
            payPrice: (this.depositsetting.roomPrice + 0).toFixed(2),
            state: 2
          })
        } else {
          var dpay = this.nowpays[0];
          dpay.payPrice = (this.depositsetting.depositReceivable + 0).toFixed(2);
          dpay.state = 1;
          var rpay = this.nowpays[1];
          rpay.payPrice = (this.depositsetting.roomPrice + 0).toFixed(2);
          rpay.state = 2;
        }
      } else {
        //押金自动录入
        if (this.depositsetting.depositsettingSwith) {
          var paysLength = this.nowpays.length
          if (paysLength == 0) {
            this.nowpays = []
            this.nowpays.push({
              nowType: this.options.paysTypeOptions[0].id,
              payPrice: (this.depositsetting.depositReceivable + 0).toFixed(2),
              state: 1
            })
          } else {
            //筛选已有押金列表
            var dList = await this.nowpays.filter(item => item.state == 1)
            if (dList.length > 0) {
              var dpay = dList[0];
              dpay.payPrice = (this.depositsetting.depositReceivable + 0).toFixed(2);
              dpay.state = 1;
            } else {
              this.nowpays.push({
                nowType: this.options.paysTypeOptions[0].id,
                payPrice: (this.depositsetting.depositReceivable + 0).toFixed(2),
                state: 1
              })
            }
          }
        }

        //收款自动录入
        if (this.depositsetting.depositShousettingSwith) {
          var paysLength = this.nowpays.length
          if (paysLength == 0) {
            this.nowpays = []
            this.nowpays.push({
              nowType: this.options.paysTypeOptions[0].id,
              payPrice: (this.depositsetting.roomPrice + 0).toFixed(2),
              state: 2
            })
          } else {
            //筛选已有收款列表
            var dList = await this.nowpays.filter(item => item.state == 2)
            if (dList.length > 0) {
              var dpay = dList[0];
              dpay.payPrice = (this.depositsetting.roomPrice + 0).toFixed(2);
              dpay.state = 2;
              if (!dpay.nowType) {
                dpay.nowType = this.options.paysTypeOptions[0].id
              }
            } else {
              this.nowpays.push({
                nowType: this.options.paysTypeOptions[0].id,
                payPrice: (this.depositsetting.roomPrice + 0).toFixed(2),
                state: 2
              })
            }
          }
        }
      }


      this.nowpaysChange()


    },
    stopDate2Change(val) {
      var startDate = moment(this.date.startDate1);
      var stopDate = moment(val);
      const date3 = stopDate.diff(startDate, 'day'); //计算相差的分钟数
      this.dataForm.days = date3;
      this.dataForm.roomsDays = date3;
      this.$nextTick(() => {
        this.getdateList();
        this.refreshRoomList(this.addRoomsList);
      });
    },

    toAccounting(item, type, printFlag) {
      //将数据存储到本地
      var p = {
        singleId: item.singleId,
        type: type,
        printFlag: printFlag,
      };
      this.$cookie.set('accounting', JSON.stringify(p));
      this.$router.push({
        name: 'accounting'
      });
    },

    addroomclick(row, column, event) {
      this.form = row;
    },


      /*
       * 读身份证
       * 参数 可选
       * Name: "张三"
       * Sex: "男"
       */
      readIdCard(index, people) {
        var CardEntity = {
          Name: "张三",
          Sex: "男"
        };
        var postData = {
          DeviceType: "IDCardHareware",
          Params: JSON.stringify(CardEntity)
        };
        this.Post(postData, "Read", index, people);
      },
      async Post(postData, methods, index, people) {
        this.istrues = 0;
        console.log(postData)
        var result;
        this.axios({
          url: this.axios.postUrl(`/api/Service/` + methods),
          method: 'POST',
          data: postData,
          cache: false,
          async: false,
          contentType: "application/json",
        }).then(async ({
          data
        }) => {
          this.istrues = 1;
          if (data.isSuccess == true) {
            var peoples = {};

          people.name = data.Name
          if (data.Sex == "男") {
            people.sex = 1
          } else {
            people.sex = 2
          }
          var list = await this.documenttypelist.filter(item => item.label == '身份证' || item.label == '居民身份证')
          if (list.length > 0) {
            people.type = list[0].id
          }
          people.number = data.IDCardNumber
          people.address = data.Address
          console.log(people)
        } else {
          this.$message({
            message: data.message,
            type: "error",
            duration: 1500
          });
        }

      })


    },
    isputile(istrues, that) {
      setTimeout(function () {
        if (istrues == 0) {
          that.$message({
            message: "接口程序未打开，请打开接口程序",
            type: "error",
            duration: 1500
          });
        }
      }, 2000);

    },

    loadPrintConfig() {
      this.$http({
        url: this.$http.adornUrl(`/hotel/thotelprinttemplate/info/9`),
        method: 'get'
      }).then(({
                 data
               }) => {
        if (data && data.code === 0) {
          this.printconfig = data.tHotelPrintTemplate;
        } else {
          this.$message.error(data.msg);
        }
      });
    },


    kasave() {
      this.dialogshow = false;
      this.visible = false;
      this.$emit('refreshDataList');
      Object.assign(this.$data, this.$options.data());
    },

    // 表单提交
    async dataFormSubmit() {
      //检查是否勾选打印登记单
      var printState = 2;
      if (this.printDengjiDan) {
        printState = 1
        this.$cookie.set('printDengjiDan', 1)
      } else {
        this.$cookie.set('printDengjiDan', 2)
      }

      //检测是否有脏房
      if (!this.ruzhuZhang) {
        this.$confirm('入住房型有脏房，是否继续入住?', '提示', {
          confirmButtonText: '确定',
          cancelButtonText: '取消',
          type: 'warning'
        }).then(() => {
          this.ruzhuZhang = true;
          this.dataFormSubmit();
        })
        return false
      }
      for (var i = 0; i < this.addRoomsList.length; i++) {
        this.addRoomsList[i].indexlength = 0;
        this.addRoomsList[i].index = i;
        var item = this.addRoomsList[i];
        console.log(item);

        if (item.reserState == 1 && !this.reserInit) {
          var today = moment().format('YYYY-MM-DD')

          var reserStartTime = moment(item.reserStartTime).format('YYYY-MM-DD')

          if (today == reserStartTime) {
            this.inquiryReserInit(item);
            return;
          }
        }


        var prices = item.prices;
        //检测选中房间是否有不支持的
        if (!prices.hoursMoney) {
          this.$message.error('当前所选房间不支持办理入住！');
          return false;
        }
        //检测是否未填写姓名
        for (var j = 0; j < item.peoples.length; j++) {
          var pop = item.peoples[j];
          console.log(pop);
          if (!pop.name) {
            this.$message.error('入住人姓名必填！');
            return false;
          }
        }
      }
      // if(this.dataForm.agreemId!=''){
      //    if(this.dataForm.agreemCustomerId==''){
      //      this.$message.error('请选择协议类型！');
      //      return false;
      //    }
      // }

      var list = await this.nowpays.filter(now => this.payInterfaceConfig.payTypeId == now.nowType)
      console.log("已选扫呗数量", list.length);
      if (list.length > 1) {
        this.$message.error("扫码支付不可用于两笔收款")
        return false;
      }

      if (this.paysActiveName == 'first') {

        for (var i = 0; i < this.nowpays.length; i++) {
          var item = this.nowpays[i]
          if (!item.nowType) {
            this.$message.error("收款方式不能为空")
            return
          }
        }
      }

      if (this.payInterfaceConfig.switchConfig == 1) {
        //触发
        var money = 0;
        this.nowpays.forEach((item, index) => {
          if (this.payInterfaceConfig.payTypeId == item.nowType) {
            money = (money + item.payPrice).toFixed(2)
          }
        })
        if (money > 0) {
          this.sbMoney = money
          this.payVisible = true;
          this.changeFocus();
          return
        }
      }


      this.$refs['dataForm'].validate(valid => {

        console.log(this.dataForm)
        if (valid) {
          this.$http({
            url: this.$http.adornUrl(`/hotel/thotelfloorroomcheckinsingle/ruzhu`),
            method: 'post',
            data: this.$http.adornData({
              id: this.dataForm.id || undefined,
              sellerId: this.dataForm.sellerId,
              printDengjiDan: this.printDengjiDan ? 1 : 2,
              userId: this.dataForm.userId,
              memberId: this.dataForm.memberId,
              checkinType: this.dataForm.checkinType,
              arrivalsTime: this.date.startDate1 + ' ' + this.date.startDate2,
              predissociationTime: this.date.stopDate1 + ' ' + this.exitPoint,
              days: this.dataForm.days,
              isDeposit: this.yajinPrice == 0 ? 0 : 1,
              sourceType: this.dataForm.sourceType,
              sourceName: this.dataForm.sourceName,
              agreemCustomerId: this.dataForm.agreemCustomerId,
              activityId: this.dataForm.activityId,
              guaranteeType: this.dataForm.guaranteeType,
              housId: this.dataForm.housId,
              saleId: this.dataForm.saleId,
              externalNo: this.dataForm.externalNo,
              remarks: this.dataForm.remarks,
              roomsNum: this.addRoomsList.length,
              roomsDays: this.dataForm.roomsDays,
              totalPrice: this.dataForm.totalPrice,
              authPrice: this.authPrice,
              collectPrice: this.yushouPrice,
              depositPrice: this.yajinPrice,
              creatTime: this.dataForm.creatTime,
              zc: this.dataForm.zc,
              sourceAgreenid: this.dataForm.sourceAgreenid,
              agreemId: this.dataForm.agreemId,
              schemeId: this.dataForm.schemeId,
              floorRooms: JSON.stringify(this.addRoomsList),
              paysType: this.paysActiveName == 'first' ? 0 : 1,
              nowpays: this.paysActiveName == 'first' ? JSON.stringify(this.nowpays) : JSON.stringify(
                this.yunowpays)
            })
          }).then(({
                     data
                   }) => {
            if (data && data.code === 0) {
              // this.$confirm('是否制房卡?', '制房卡', {
              //         confirmButtonText: '是',
              //         cancelButtonText: '否',
              //              customClass:'ceswidth',
              //         center:true,
              //         showClose:false,

              //         type: 'warning'
              //       }).then(() => {
              //      this.DoorNewCard(this.addRoomsList);

              if (this.printDengjiDan) {
                var pdata = data.vo
                console.log("pdata", pdata)
                this.$refs.djrz80.setData(pdata);
                this.$refs.djrz58.setData(pdata);
                this.$refs.djrzA5.setData(pdata);
              }

              this.$message({
                message: this.$t('Common.OperationSuccessful'),
                type: 'success',
                duration: 1000,
                onClose: () => {
                  if (this.printDengjiDan) {
                    this.printRuzhu();
                  }
                  this.showzhika();
                  this.form = this.addRoomsList[0];
                  this.sid = data.singleId
                }
              });
            } else {
              this.$message.error(data.msg);
            }
          });
        }
      });
    },
    showzhika() {
      this.$http({
        url: this.$http.adornUrl('/hotel/tsellerroomcard/list'),
        method: 'get',
        params: this.$http.adornParams({})
      }).then(({data}) => {
        if (data && data.code === 0) {
          if (data.page.list != null && data.page.list.length != 0) {
            if (data.page.list[0].status == 1) {
              this.dialogshow = true;
            } else {
              this.dialogshow = false;
              this.visible = false;
              this.$emit('refreshDataList');
              // Object.assign(this.$data, this.$options.data());
            }
          } else {
            this.dialogshow = false;
            this.visible = false;
            this.$emit('refreshDataList');
          }
        } else {

        }
      })

    },

    printRuzhu() {
      this.$nextTick(() => {
        setTimeout(() => {
          LODOP = getLodop();
          if (!LODOP) {
            this.$alert(
              `<br><font color='#FF00FF'>CLodop云打印服务(localhost本地)未安装启动!点击这里<a href='http://www.lodop.net/download/CLodop_Setup_for_Win32NT_4.088Extend.zip' download target='_self'>执行安装</a>,安装后请刷新页面。</font>`,
              '安装', {
                confirmButtonText: '确定',
                dangerouslyUseHTMLString: true
              }
            );
            return;
          }
          //样式
          // 假设您已经有了一个包含HTML内容的字符串，我们可以直接在这个字符串中添加CSS样式
          var printContent = '<style>' +
            '.print-content { font-size: 8px; }' + // 设置字体大小为8px
            '</style>' +
            '<div class="print-content">' +
            (this.$refs.djrz80 ? this.$refs.djrz80.$el.innerHTML : '') + // 确保这里的内容是正确的
            '</div>';

          // 设置纸张大小
          LODOP.SET_PRINT_PAGESIZE(2000, 2000, 'mm');

          // 增加超文本项
          LODOP.ADD_PRINT_HTM(0, 0, '100%', '100%', printContent);

           // 设置打印份数
          LODOP.SET_PRINT_COPIES(this.printconfig.printSum || 1);

           // 如果需要设置LODOP的授权信息，请确保这些调用在适当的位置（通常是在页面加载或初始化时）
          LODOP.SET_LICENSES("", "4B44F795076C8F14211A5ED0A5339305DAB", "23580B189D96F33252722697A57AC00506B", "");

          if (this.printconfig.preview) {
            if (LODOP.SET_PRINTER_INDEXA(this.printconfig.defaultPrint)) {
              LODOP.SET_PRINTER_INDEXA(this.printconfig.defaultPrint);
              LODOP.PRINT();
              // LODOP.PRINT_DESIGN();
            } else {
              LODOP.SET_PRINTER_INDEXA(0);
              LODOP.PRINT();
              // LODOP.PRINT_DESIGN();
            }
          } else {
            if (LODOP.SET_PRINTER_INDEXA(this.printconfig.defaultPrint)) {
              LODOP.SET_PRINTER_INDEXA(this.printconfig.defaultPrint);
              LODOP.PREVIEW();
            } else {
              LODOP.SET_PRINTER_INDEXA(0);
              LODOP.PREVIEW();
              // LODOP.PRINT_DESIGN();
            }
          }
        }, 100)

      });
    },
    getPayInterface() {
      this.$http({
        url: this.$http.adornUrl(`/hotel/thotelsellerpayinterfaceconfig/myInfo`),
        method: 'get'
      }).then(({
                 data
               }) => {
        if (data && data.code === 0) {
          this.payInterfaceConfig = data.tHotelSellerPayInterfaceConfig
        } else {
          this.$message.error("加载支付配置失败")
        }
      })
    },
    //制卡
    DoorNewCard(item2) {
      this.addRoomsList[item2.index].indexlength = this.addRoomsList[item2.index].indexlength + 1;
      this.kaindex = this.kaindex + 1;
      this.doorLockParams.OpeartorType = "NewCard";
      this.getkk(item2);
    },
    //注销卡
    DoorCancelCard(item) {

      this.doorLockParams.OpeartorType = "CancelCard";
      this.getkk(item);
    },

    //复制卡
    DoorCopyCard(item2) {
      this.addRoomsList[item2.index].indexlength = this.addRoomsList[item2.index].indexlength + 1;
      this.kaindex = this.kaindex + 1;
      this.doorLockParams.OpeartorType = "CopyCard";
      this.getkk(item2);
    },
    getkk(item2) {
      // methods["id"]=
      // console.log(methods)
      var result;
      this.$http({
        url: this.$http.adornUrl(`/hotel/business/Write`),
        method: 'post',
        data: this.$http.adornParams({
          id: item2.id,
          singleId: this.sid
        })
      }).then(({
                 data
               }) => {
        this.doorLockParams.RoomNumber = data.roomNumber;
        this.doorLockParams.StartDate = data.StartDate;
        this.doorLockParams.EndDate = data.endDate;
        this.doorLockParams.CardID = data.CardID;
        this.doorLockParams.skr = data.skr;
        this.doorLockParams.sfz = data.sfz;
        this.doorLockParams.floorCengId = data.floorCengId
        this.doorLockParams.floorId = data.floorId
        this.doorLockParams.CardNum = data.CardNum;
        this.doorWriteCard(this.doorLockParams);
      });
    },
    doorWriteCard(doorLockParams) {
      var postData = {
        DeviceType: "DoorLockHareware",
        Params: JSON.stringify(doorLockParams)
      };
      this.Posts(postData, "Write");
    },
    Posts(postData, methods) {
      console.log(postData)
      var result;
      this.istrues = 0;
      this.axios({
        url: this.axios.postUrl(`/api/Service/` + methods),
        method: 'POST',
        data: postData,
        cache: false,
        async: false,
        contentType: "application/json",
      }).then(({
                 data
               }) => {

        if (data.isSuccess == true) {
          this.istrues = 1;
          this.$message({
            message: "操作成功",
            type: "success",
            duration: 1500
          });
          this.savedataForm();
        } else {
          this.istrues = 1;
          this.$message({
            message: data.message,
            type: "error",
            duration: 1500
          });
        }

      })


    },
    savedataForm() {
      this.dataFormsa.skTime = this.doorLockParams.StartDate
      this.dataFormsa.zkUser = this.doorLockParams.skr
      this.dataFormsa.roomNum = this.doorLockParams.CardNum
      this.dataFormsa.kaNo = this.doorLockParams.RoomNumber
      this.dataFormsa.endTime = this.doorLockParams.EndDate
      this.dataFormsa.creatTime = this.doorLockParams.StartDate
      this.dataFormsa.floorCengId = this.doorLockParams.floorCengId
      this.dataFormsa.floorId = this.doorLockParams.floorId


      if (this.doorLockParams.OpeartorType == "NewCard") {
        this.dataFormsa.operation = "制新卡";
      } else if (this.doorLockParams.OpeartorType == "CopyCard") {
        this.dataFormsa.operation = "复制卡";
      } else {
        this.dataFormsa.operation = "注销卡";
      }
      this.$http({
        url: this.$http.adornUrl(`/hotel/tgatecard/save`),
        method: 'post',
        data: this.$http.adornData({
          'skTime': this.dataFormsa.skTime,
          'zkUser': this.dataFormsa.zkUser,
          'roomNum': this.dataFormsa.roomNum,
          'kaNo': this.dataFormsa.kaNo,
          'creatUserId': "",
          'sid': this.sid,
          'endTime': this.dataFormsa.endTime,
          'ckSfz': this.dataFormsa.ckSfz,
          'operation': this.dataFormsa.operation,
          'creatTime': this.dataFormsa.creatTime,
          'floorCengId': this.dataFormsa.floorCengId,
          'floorId': this.dataFormsa.floorId
        })
      }).then(({
                 data
               }) => {
        if (data && data.code === 0) {

        } else {
          this.$message.error(data.msg)
        }
      })
    },
    changeFocus() {
      this.$nextTick(() => {
        this.$refs.inputFocus.focus();
      })
    },
    async nowpaysChangeSelect(item) {
      if (this.payInterfaceConfig.switchConfig == 1) {
        //触发
        if (this.payInterfaceConfig.payTypeId == item.nowType) {
          //是否已经存在了
          var list = await this.nowpays.filter(now => this.payInterfaceConfig.payTypeId == now.nowType)
          console.log("已选扫呗数量", list.length);
          if (list.length > 1) {
            this.$message.error("已选择扫码支付")
            item.nowType = '';
            return false;
          }
        }
      }
    },
    authClose() {
      //计算金额

      // this.payVisible = false;
      this.payLoding = true;
      //扫码支付请求数据
      this.$http({
        url: this.$http.adornUrl('/hotel/thotelsellerpayinterfaceconfig/preAuthBar'),
        method: 'post',
        data: this.$http.adornData({
          'type': 2, //正式
          'auth_no': this.auth_no, //授权码，客户的付款码
          'total_fee': this.sbMoney * 100, //金额，单位分
          'order_body': '入住', //订单描述
          'attach': '入住', //附加数据,原样返回
        })
      }).then(({
                 data
               }) => {
        if (data && data.code === 0) {
          console.log(data)
          this.payVisible = false
          //保存入账信息
          this.auth_no = "";
          this.payLoding = false;
          var terminalTrace = data.data.terminalTrace
          this.authSubForm(terminalTrace);
        } else if (data.code == 3) {
          //循环查询订单，直至成功或失败
          this.timer = setInterval(() => {
            this.queryOrder(data.data);
          }, 1500);
        } else {
          this.payLoding = false;
          this.auth_no = "";
          this.payVisible = false
          this.$message.error(data.msg);
        }
      })
    },
    queryOrder(data) {
      this.$http({
        url: this.$http.adornUrl('/hotel/thotelsellerpayinterfaceconfig/commonQuery'),
        method: 'post',
        data: this.$http.adornData({
          'pay_type': data.payType,
          'terminal_trace': data.terminalTrace,
          'terminal_time': data.terminalTime,
          'out_trade_no': data.outTradeNo,
        })
      }).then(({
                 data
               }) => {
        console.log(data)
        if (data && data.code === 0) {
          clearInterval(this.timer)
          this.payLoding = false;
          console.log(data)
          this.payVisible = false
          this.auth_no = "";
          //保存入账信息
          var terminalTrace = data.data.terminalTrace
          this.authSubForm(terminalTrace);
        } else if (data.code === 3) {

        } else {
          clearInterval(this.timer)
          this.payLoding = false;
          this.payVisible = false
          this.auth_no = "";
          this.$message.error(data.msg);
        }
      })
    },
    authSubForm(terminalTrace) {
      let _this = this
      _this.nowpays.forEach((item, index) => {
        if (_this.payInterfaceConfig.payTypeId == item.nowType) {
          item["sb"] = "1"
        } else {
          item["sb"] = "2"
        }
      })
      setTimeout(function () {
        _this.$http({
          url: _this.$http.adornUrl(`/hotel/thotelfloorroomcheckinsingle/ruzhu`),
          method: 'post',
          data: _this.$http.adornData({
            terminalTrace: terminalTrace,
            id: _this.dataForm.id || undefined,
            sellerId: _this.dataForm.sellerId,
            printDengjiDan: _this.printDengjiDan ? 1 : 2,
            userId: _this.dataForm.userId,
            memberId: _this.dataForm.memberId,
            checkinType: _this.dataForm.checkinType,
            arrivalsTime: _this.date.startDate1 + ' ' + _this.date.startDate2,
            predissociationTime: _this.date.stopDate1 + ' ' + _this.exitPoint,
            days: _this.dataForm.days,
            isDeposit: _this.yajinPrice == 0 ? 0 : 1,
            sourceType: _this.dataForm.sourceType,
            sourceName: _this.dataForm.sourceName,
            agreemCustomerId: _this.dataForm.agreemCustomerId,
            activityId: _this.dataForm.activityId,
            guaranteeType: _this.dataForm.guaranteeType,
            housId: _this.dataForm.housId,
            saleId: _this.dataForm.saleId,
            externalNo: _this.dataForm.externalNo,
            remarks: _this.dataForm.remarks,
            roomsNum: _this.addRoomsList.length,
            roomsDays: _this.dataForm.roomsDays,
            totalPrice: _this.dataForm.totalPrice,
            authPrice: _this.authPrice,
            collectPrice: _this.yushouPrice,
            depositPrice: _this.yajinPrice,
            creatTime: _this.dataForm.creatTime,
            zc: _this.dataForm.zc,
            sourceAgreenid: _this.dataForm.sourceAgreenid,
            agreemId: _this.dataForm.agreemId,
            schemeId: _this.dataForm.schemeId,
            floorRooms: JSON.stringify(_this.addRoomsList),
            paysType: _this.paysActiveName == 'first' ? 0 : 1,
            nowpays: _this.paysActiveName == 'first' ? JSON.stringify(_this.nowpays) : JSON.stringify(
              _this.yunowpays)
          })
        }).then(({
                   data
                 }) => {
          if (data && data.code === 0) {
            if (_this.printDengjiDan) {
              var pdata = data.vo
              console.log("pdata", pdata)
              _this.$refs.djrz80.setData(pdata);
              _this.$refs.djrz58.setData(pdata);
              _this.$refs.djrzA5.setData(pdata);
            }
            _this.$message({
              message: _this.$t('Common.OperationSuccessful'),
              type: 'success',
              duration: 1000,
              onClose: () => {
                if (_this.printDengjiDan) {
                  _this.printRuzhu();
                }
                _this.dialogshow = true;
                _this.form = _this.addRoomsList[0];
                _this.sid = data.singleId
              }
            });
          } else {
            _this.$message.error(data.msg);
          }
        });
      }, 1000);
    },
  }
};
</script>
<style lang="scss" scoped>
.ant-card-bordered,
.ant-card-head,
.ant-table-bordered table,
.ant-table-bordered td,
.ant-table-bordered th {
  border-color: #d9e5ec !important;
}

.ant-card-head-wrapper {
  display: flex;
  align-items: center;
}

.ant-card-head-title {
  display: inline-block;
  flex: 1 1;
  padding: 8px 0;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.ant-card-head:after {
  clear: both;
}

.ant-card-head:after,
.ant-card-head:before {
  content: '';
  display: table;
}

.ant-card-body,
.ant-card-wider-padding .ant-card-body {
  padding: 16px;
}

.ruzhu-left {
  .is-hover-shadow:nth-child(1) {
    padding-right: 20px;
  }

  .el-input,
  .el-select,
  .el-input-number,
  .el-date-editor.el-input,
  .el-date-editor.el-input__inner {
    width: 180px;
  }
}


.ant-layout-footer {
  background: #fff;
  text-align: right;
  border-top: 1px solid #e8e8e8;
  margin-top: 30px;
}

.ant-layout-footer {
  padding: 12px 24px;
  color: #002140;
  font-size: 14px;
  background: #d9e5ec;
  bottom: 0px;
  width: 100%;
  left: 0px;
}

.el-button + .el-button {
  margin-left: 8px;
}

.title_day_price {
  padding: 0 0 15px;
  border-bottom: 1px solid rgba(0, 0, 0, 0.25);
}

.title_day_price > .pull {
  font-weight: 700;
  margin-top: 6px;
}

.pull {
  float: left;
}

.clear_float:after {
  display: block;
  content: '';
  clear: both;
}

.title_day_price > .pull .in_block + .in_block {
  margin-left: 30px;
}

.push {
  float: right;
}

.in_block {
  display: inline-block;
}

.title_day_price > .pull .in_block > span:first-of-type {
  color: #666;
}

.title_day_price > .pull .in_block > span:nth-of-type(2) {
  color: #151515;
}

.red_color1 {
  color: #f24e4c !important;
}

.error_html .text {
  font-size: 14px;
  margin-top: 20px;
  margin-bottom: 20px;
}

.error_html {
  text-align: center;
  color: #000;
}

.el-form-item.in_block {
  margin-bottom: 8px;
}

.el-form-item {
  margin-bottom: 15px;
}

.add_room_cell .col_one {
  padding: 10px 0;
}

.push {
  float: right;
}

.pull {
  float: left;
}

.push a:hover {
  text-decoration: none;
  cursor: pointer;
}

.ant-divider,
.ant-divider-vertical {
  position: relative;
  top: -0.06em;
  display: inline-block;
  width: 1px;
  height: 0.9em;
  margin: 0 8px;
  vertical-align: middle;
}

.ant-divider {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  color: #002140;
  font-size: 14px;
  font-variant: tabular-nums;
  line-height: 1.5;
  list-style: none;
  -webkit-font-feature-settings: 'tnum', 'tnum';
  font-feature-settings: 'tnum', 'tnum';
  background: #e8e8e8;
}

.pull > span,
.add_room_cell .col_two > .pull > span {
  display: inline-block;
}

.pull > span + span {
  margin-left: 30px;
}

.customerSourceBar {
  padding: 8px 16px;
  box-shadow: 0 2px 6px 0 rgba(0, 0, 0, .09);
}

@media screen and (min-width: 1441px) {
  .customerSourceBar {
    margin-left: auto;
    margin-right: auto;
  }
}

.customerSourceBar > div > .in_block:nth-of-type(2) {
  width: 37%;
}

.customerSourceBar > div > .in_block:first-of-type {
  width: 26%;
}

.in_block {
  display: inline-block;
}

.ant-form label {
  font-size: 14px;
}

.ruzhu #pane-first {
  max-height: 150px;
  overflow-y: auto;
}


[v-cloak] {
  display: none;
}

.el-dialog__wrapper {
  /deep/ .el-dialog__body {
    padding-top: 0;
    overflow: auto;
  }

  /deep/ .el-card__body {
    padding-top: 0;
    padding-left: 0;
    padding-bottom: 0;
  }

  /deep/ .el-card__header {
    padding-bottom: 0;
  }

  /deep/ .ant-card-body {
    padding-bottom: 0;
  }

  /deep/ .is-fullscreen {
    .el-dialog__body {
      max-height: none;
    }
  }

  /deep/ .el-form-item {
    margin-bottom: 10px;
  }
}

.el-dialog__wrapper /deep/ .el-dialog {
  width: 85%;
}

.famensuoka {
  &.el-dialog__wrapper /deep/ .el-dialog {
    width: 60%;
  }

  .el-tag + .el-tag {
    margin-left: 20px;
  }

  /deep/ td {
    text-align: center;
  }

  /deep/ .cell {
    text-align: center;
  }

  .el-form /deep/ {

    .el-form-item__content,
    & .el-date-editor.el-input {
      width: 160px;
    }
  }

  .el-button {
    margin-bottom: 20px;
  }

  .el-dialog__body {
    margin-bottom: 0;
  }

  .el-form-item:nth-child(2) /deep/ .el-form-item__content {
    width: 270px;
  }

  /deep/ .el-table__body-wrapper {
    text-align: center;
    max-height: 400px;
    overflow-x: hidden;
    overflow-y: auto;
  }

  /deep/ .el-table {
    margin-bottom: 15px;
  }
}

@media (min-width: 1400px) {
  .ruzhu-dangbbao {
    .el-select {
      width: 150px;
    }
  }
}

@media only screen and (max-width: 1280px) {
  .el-dialog__wrapper /deep/ .el-dialog {
    width: 100%;
  }
}

@media screen and (max-width: 1400px) {
  .el-dialog__wrapper /deep/ .ant-card-body-other {
    .el-row {
      display: flex;
      flex-wrap: wrap;

      .el-col {
        width: 100%;
      }
    }
  }

  .ant-layout-footer {
    margin-top: 13px;
  }

  .famensuoka {
    &.el-dialog__wrapper /deep/ .el-dialog {
      width: 80%;
    }
  }

  .el-dialog__wrapper /deep/ .el-date-editor.ruzhu-ruzhushij {
    width: 120px;
    margin-left: 40px;
  }
}

.ant-popover-inner-content {
  padding: 12px 16px;
  color: #002140;

  .table_recent_price_ul {
    max-width: 900px;

    table {
      border-collapse: collapse;
      width: 100%;

      thead,
      th,
      tr,
      tt,
      u,
      ul,
      {
        font: inherit;
        font-size: 100%;
        margin: 0;
        padding: 0;
        vertical-align: initial;
        border: 0;
      }


    }

  }

}

.recent_price_ul table th > .list_box > span {
  line-height: 36px;
  background: #f0f0f0;
  height: 36px;
}

.table_recent_price_ul.table_recent_price_ul table tbody tr td:first-of-type .list_box span {
  height: calc(100% + 1px);
}

.recent_price_ul table td > .list_box > span {
  height: 95px;
}

.recent_price_ul table td > .list_box > span,
.recent_price_ul table th > .list_box > span {
  float: left;
  width: 150px;
  text-align: center;
  border: 1px solid rgba(0, 0, 0, .25);
  margin-left: -1px;
  margin-top: -1px;
}

.recent_price_ul table td:first-of-type > .list_box span > div:first-of-type,
.recent_price_ul table td > .list_box > span > div:first-of-type {
  margin-top: 8px;
  margin-bottom: 6px;
}

.table_recent_price_ul.table_recent_price_ul td:nth-of-type(2) .list_box {
  max-height: 340px;
  overflow: auto;
}
</style>

